package cn.edu.buaa.treehole.dao;

import cn.edu.buaa.treehole.dao.exception.*;

import java.util.Set;

/*
* @author Deng XinYu
* */
public interface SignatureDao {

    /*
    * normal_behaviour:
    *   Pre-Condition:
    *       { select * from signature_table where PID=pid and SIGNATURE=signature } != None;
    *   Post-Condition:
    *       \result == { select NAME from signature_table where PID=pid and SIGNATURE=signature }
    *
    * exception_behaviour:
    *   Pre-Condition:
    *       { select * from signature_table where PID=pid and SIGNATURE=signature } != None;
    *   \raise SignatureNotExistException;
    * */
    String getName(long pid, String signature) throws SignatureNotExistException, DaoException;

    /*
    * normal_behaviour:
    *   Pre-Condition:
    *       { select * from signature_table where PID=pid and SIGNATURE=signature } == None;
    *       { select * from signature_table where PID=pid and NAME=name } == None;
    *   Post-Condition:
    *       name == { select NAME from signature_table where PID=pid and SIGNATURE=signature }
    *       signature == { select NAME from signature_table where PID=pid and NAME=name }
    *
    * exception_behaviour:
    *   Pre-Condition:
    *       { select * from signature_table where PID=pid and SIGNATURE=signature } != None;
    *   \raise SignatureHasExistException;
    *
    * exception_behaviour:
    *   Pre-Condition:
    *       { select * from signature_table where PID=pid and NAME=name } != None;
    *   \raise NameHasExistException;
    * */
    void addName(long pid, String signature, String name) throws SignatureHasExistException, NameHasExistException, DaoException;

    /*
    * normal_behaviour:
    *   Pre-Condition:
    *       { select * from signature_table where PID=pid } != None;
    *   Post-Condition:
    *       \result == ({ select * from signature_table where PID=pid and NAME=name } != None)
    *
    * exception_behaviour:
    *   Pre-Condition:
    *       { select * from signature_table where PID=pid } == None;
    *   \raise PidNotExistException;
    * */
    boolean containName(long pid, String name) throws PidNotExistException, DaoException;

    /*
    * normal_behaviour:
    *   Pre-Condition:
    *       { select * from signature_table where PID=pid } != None;
    *   Post-Condition:
    *       \result == ({ select * from signature_table where PID=pid and SIGNATURE=signature } != None)
    *
    * exception_behaviour:
    *   Pre-Condition:
    *       { select * from signature_table where PID=pid }.size() == 0;
    *   \raise PidNotExistException;
    * */
    boolean containSignature(long pid, String signature) throws PidNotExistException, DaoException;


    /*
    * Post-Condition:
    *   \result == { select * from signature_table where PID=pid }.size();
    * */
    int getCount(long pid) throws DaoException;
}